const app = getApp();
Page({

  data: {

  },
  goSurveyTap: function (event) {
    console.log(event)
    var that = this;
    var uid = event.currentTarget.dataset.id;
    var name = event.currentTarget.dataset.name;
    wx.navigateTo({
      url: '../survey/survey?id=' + uid + '&name=' + name,
    })
  },
  goRealtimeTap: function (event) {
    var that = this;
    var uid = event.currentTarget.dataset.id;
    var name = event.currentTarget.dataset.name;
    wx.navigateTo({
      url: '../realtime/realtime?id=' + uid + '&name=' + name,
    }) 
  },
  /**
   * 页面的初始数据
   */


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var _this = this;
    console.log(options)
    // 获取游戏产品ID和名称 获取贴纸详情
    var oid = options.id;
    var name = options.name;
    _this.setData({
      oid: oid,
      name: name
    })

    this.requestAPI(oid);

  },
  requestAPI:function(oid){
    var _this = this;
    wx.request({
      url: 'https://data1.cqhot.cn/index.php?s=/Admin/Apiwx/order_detail',
      data:{
        id:oid
      },
      success:function(res){
        console.log(res)
        var data = res.data.data.detail;
        _this.setData({
          company:data.company,
          get_type: data.get_type,
          id: data.id,
          money: data.money,
          xs_name: data.name,
          order_type: data.order_type,
          pay_surplus: data.pay_surplus,
          product_type: data.product_type,
          surplus_time: data.surplus_time,
          uid: res.data.data.user.uid
        })
        if (res.data.data.user.portrait == null) {
          _this.setData({
            portrait: "../../images/headimg.jpg",
          })
        } else {
          _this.setData({
            portrait: res.data.data.user.portrait,
          })
        }

      }
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function (res) {
    return {
      title: 'CRM助手',
      path: '/pages/survey/survey',
      success: function () { },
      fail: function () { }
    }
  },
})